package com.xsjl.article.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xsjl.article.pojo.Article;
import com.xsjl.article.pojo.ArticleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * article数据访问接口
 * @author Administrator
 *
 */
@Mapper
// @Repository
public interface ArticleMapper extends BaseMapper<Article> {

    @Update("update tb_article set state='1' where id=#{articleId}")
    void updateState(String articleId);

    @Update("update tb_article set thumbup=thumbup + 1 where id=#{articleId}")
    void addThumbup(String articleId);

    @Select("SELECT a.id,a.userid,a.title,a.content,a.image,a.createtime,a.updatetime,a.ispublic,a.istop,a.visits,a.thumbup,a.`comment`,a.state,a.url,b.avatar, b.username FROM `tb_article` a left join xy_user.tb_user b on a.userid=b.id order by createtime desc")
    List<ArticleVO> findAll();
}
